/*
DIP packet
*/


#ifndef __dip_packet_h__
#define __dip_packet_h__

//#include <config.h>
//#include "dip.h"
#define DIP_MAX_ERRORS 100


/* =====================================================================
   Packet Formats...
   ===================================================================== */
#define DIPTYPE_HELLO  	0x01
//#define DIPTYPE_RERR   	0x02


/*
 * DIP Routing Protocol Header Macros
 */

#define HDR_DIP_HELLO(p)	((struct hdr_dip_hello*)hdr_dip_hello::access(p))


struct hdr_dip_hello {
        u_int8_t        ah_type;        // Packet Type
        u_int8_t        reserved[2];
        
        nsaddr_t        rp_dst;                 // Destination IP Address

        //nsaddr_t        rp_src;                 // Source IP Address
        //double	        rp_lifetime;            // Lifetime

        //double          rp_timestamp;           // when corresponding REQ sent;
						// used to compute route discovery latency
		// Header access methods
	static int offset_; // required by PacketHeaderManager
	inline static int& offset() { return offset_; }
	inline static hdr_dip_hello* access(const Packet* p) {
		return (hdr_dip_hello*) p->access(offset_);
	}						
  inline int size() { 
  int sz = 0;
  /*
  	sz = sizeof(u_int8_t)		// rp_type
	     + 2*sizeof(u_int8_t) 	// rp_flags + reserved
	     + sizeof(u_int8_t)		// rp_hop_count
	     + sizeof(double)		// rp_timestamp
	     + sizeof(nsaddr_t)		// rp_dst
	     + sizeof(u_int32_t)	// rp_dst_seqno
	     + sizeof(nsaddr_t)		// rp_src
	     + sizeof(u_int32_t);	// rp_lifetime
  */
  	sz = 9*sizeof(u_int8_t);
  	assert (sz >= 0);
	return sz;
  }

};


#endif /* __dip_packet_h__ */
